]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
[panel] Handle async load of icons correctly
authorColin Walters <walters@verbum.org>
Sun, 28 Feb 2010 20:51:28 +0000 (15:51 -0500)
committerColin Walters <walters@verbum.org>
Sun, 28 Feb 2010 20:53:22 +0000 (15:53 -0500)
Fading the application icon required the texture to have already been
loaded, which was normally the case since we create icons for apps
in the well and browser; but when finding an app not from there,
the cogl-texture for the icon might not be available.

Fix this by watching for the texture and fading when it appears.

https://bugzilla.gnome.org/show_bug.cgi?id=611288

js/ui/panel.js

index d9e40ce266a717ae7075d6d4f0fe8087ef7ba594..da56cb1745e96353f3c0f84f597138e1346a1ddc 100644 (file)
@@ -152,12 +152,13 @@ AppPanelMenu.prototype = {
         this._activeSequence = null;
         this._startupSequences = {};
 
-        this.actor = new St.Bin({ name: 'appMenu', });
+        this.actor = new St.Bin({ name: 'appMenu' });
         this._container = new Shell.GenericContainer();
         this.actor.set_child(this._container);
         this._container.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
         this._container.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
         this._container.connect('allocate', Lang.bind(this, this._allocate));
+        this._sourceIcon = null;
         this._iconBox = new Shell.Slicer({ name: 'appMenuIcon' });
         this._container.add_actor(this._iconBox);
         this._label = new TextShadower();
@@ -263,9 +264,21 @@ AppPanelMenu.prototype = {
         } else {
             icon = null;
         }
-        
+
         if (icon != null) {
-            let faded = Shell.fade_app_icon(icon); /* TODO consider caching */
+            if (this._sourceIcon != null)
+                this._sourceIcon.destroy();
+            this._sourceIcon = icon;
+            let faded = Shell.fade_app_icon(icon);
+            // Because loading the texture is async, we may not have it yet.
+            // If we don't, just create an empty one for now.
+            if (faded == null)
+                faded = new Clutter.Texture({ width: AppDisplay.APPICON_SIZE,
+                                              height: AppDisplay.APPICON_SIZE });
+            this._sourceIcon.connect('notify::cogl-texture', Lang.bind(this, function () {
+                faded = Shell.fade_app_icon(icon);
+                this._iconBox.set_child(faded);
+            }));
             this._iconBox.set_child(faded);
             this._iconBox.show();
         }